Brute zip with generating pass lists 5 bytes str + int caused for truncated
Get archive.zip and history and password.txt
History is like .bash_history :
2229 nano password.txt
2231 zip -e archive.zip maleo.log
2232 cp password.txt backuppassword.txt
2234 truncate -s -5 password.txt
2235 cat password.txt
2236 cat backuppassword.txt
2237 rm -rf backuppassword.txt
and password is
703435356B756E
'truncate -s 5' means remove 5 bytes. before it was i got tricked. because i think 5 bytes mean 5 chars. so make pass lists with 5 chars. but i'm wrong. because if i put 4 chars the size show me its 5 bytes. example:
so truncate -s -5 means delete 4 chars. ( 5 byte = 4 chars )
so this is my solver:
import string, itertools
text = string.ascii_letters.upper()
number = string.digits
original = "703435356B756E"
def generate_len(length: int) -> list:
characters = number+text
return [''.join(p) for p in itertools.product(characters, repeat=length)]
if __name__ == "__main__":
pass_lists = generate_len(4)
for password in pass_lists:
print(original+password)
python3 gen.py > pass_4_char_and_digits.pass
zip2john archive.zip > hash_archive
john hash_archive --wordlist=pass_4_char_and_digits.pass
john --show archive_hash
archive.zip/maleo.log:703435356B756EAE3F:maleo.log:archive.zip::archive.zip
1 password hash cracked, 0 left
analyse and grab the hidden text in .log file ( description results is more then 10 coins )
import re, base64
def main():
pattern = r"send (.*?) coin\.\.\.\.\n.*give '(.*?)' for reward"
with open('maleo.log', 'r') as f:
matches = re.findall(pattern, f.read())
output = ""
for coins, reward in matches:
if int(coins) >= 10:
output += reward
print(reward, end="")
print(base64.b64decode(output))
if __name__ == "__main__":
main()
TechnoFairCTF{L0g_aja_b4ng_c333k}